MACRO(OSGSWIG_ADD_MODULE)

	# Parameters can't be looked up like this: ${ARGV${num}}
	
	SET(NAME   ${ARGV0})
	SET(TARGET ${ARGV1})
	
	SET(LIB_0 ${ARGV2})
	SET(LIB_1 ${ARGV3})
	SET(LIB_2 ${ARGV4})
	SET(LIB_3 ${ARGV5})
	SET(LIB_4 ${ARGV6})
	SET(LIB_5 ${ARGV7})
	SET(LIB_6 ${ARGV8})
	SET(LIB_7 ${ARGV9})
	
	SET_SOURCE_FILES_PROPERTIES(${NAME}.i PROPERTIES CPLUSPLUS TRUE)
	
	SWIG_ADD_MODULE(${NAME} ${TARGET} ${NAME}.i)
	
	SET(${NAME}_MODULE_LIBS ${LIB_0} ${LIB_1} ${LIB_2} ${LIB_3} ${LIB_4} ${LIB_5} ${LIB_6} ${LIB_7})
	
	SWIG_LINK_LIBRARIES(${NAME} ${${NAME}_MODULE_LIBS})
	
	# from Luigi Calory
	IF(WIN32)
		SET(TGT ${SWIG_MODULE_${NAME}_REAL_NAME}) 
		GET_TARGET_PROPERTY(${TGT}_LOCATION ${TGT} LOCATION)
		GET_FILENAME_COMPONENT( MYNAME ${${TGT}_LOCATION} NAME_WE)
		GET_FILENAME_COMPONENT( MYDIR ${${TGT}_LOCATION} PATH)
		GET_FILENAME_COMPONENT( PARDIR ${MYDIR} PATH)

		ADD_CUSTOM_COMMAND(TARGET ${TGT}
			POST_BUILD
			COMMAND ${CMAKE_COMMAND}
			ARGS -E copy ${${TGT}_LOCATION} "${PARDIR}/${MYNAME}.pyd"
			)
			
	ENDIF(WIN32)
ENDMACRO(OSGSWIG_ADD_MODULE)

# usage
# OSGSWIG_ADD_MODULE(osg python ${OSG_LIBRARY})
